import { defineStore } from "pinia";
import { get } from "@/utils/request";
import {ref} from 'vue'

export const useStudentSituationStore = defineStore('studentSituation',() => {
  let stuSituationProceedData = ref(null)
  let stuSituationFinishData = ref(null)
  // 进行中表单数据
  const stuSituationProceedRequest = async () => {
    try {
      const response = await get('/student/worklist')
      console.log(response)
      // if(response.code == 200) {
        stuSituationProceedData.value = response.data
        console.log(stuSituationProceedData)
      // }
    }catch(error){
      console.log(localStorage.getItem('token'))
      console.error('获取学业情况失败:', {
      message: error.message,
      stack: error.stack
      })
      // 显示用户友好的错误提示
      // ElMessage.error(`获取学业情况失败: ${error.message}`)
    }
  }

  // 已完成表单数据
  const stuSituationFinishRequest = async () => {
    try {
      const response = await get('/student/worklistover')
      console.log(response)
      // if(response.code == 200) {
        stuSituationFinishData.value = response.data
        console.log(stuSituationFinishData.value)
      // }
    }catch(error){
      console.error(error)
    }
  }

  return {stuSituationProceedData,stuSituationProceedRequest,stuSituationFinishData,stuSituationFinishRequest}
})